package com.bingbing.back.service.Impl;

import com.bingbing.back.dto.ConsultInfoDto;
import com.bingbing.back.dto.StuInfoDto;
import com.bingbing.back.mapper.ConsultInfoMapper;
import com.bingbing.back.mapper.StuInfoMapper;
import com.bingbing.back.po.ConsultInfo;
import com.bingbing.back.po.StuInfo;
import com.bingbing.back.service.ConsultInfoService;
import com.bingbing.back.service.StuInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StuInfoServiceImpl implements StuInfoService {
    @Resource
    private StuInfoMapper stuInfoMapper;
    @Resource
    private ConsultInfoMapper consultInfoMapper;

    @Override
    public int dofindByConsultId(Integer consultId){
        Integer row=0;
        row=stuInfoMapper.findByConsultId(consultId);
        return row;
    }

    @Override
    public PageInfo<StuInfo> findByParam(int pageNum,int pageSize,StuInfoDto dto){
        PageInfo<StuInfo> page=null;
        PageHelper.startPage(pageNum,pageSize);
        List<StuInfo> ads=stuInfoMapper.findByParam(dto);
        page=new PageInfo<>(ads);
        return page;
    }

    @Override
    public int doDelete(Integer stuId){
        int row=0;
        row=stuInfoMapper.delete(stuId);
        return row;
    }

    @Override
    public List<ConsultInfo> showAbleConsult() {
        return consultInfoMapper.showAbleConsult();
    }

    @Override
    public int updateConsult(int stuId, int consultId) {
        return stuInfoMapper.updateConsult(stuId, consultId);
    }
}
